<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>组件的遍历  列表</title>
</head>
<body>
    <div id="root"></div>

    <script src="../js/react.development.js"></script>
    <script src="../js/react-dom.development.js"></script>
    <script src="../js/babel.min.js"></script>

    <script type="text/babel">
        //1. 准备数据
        let students = [
            {name: '张三', age:20, gender: '男'},
            {name: '孙红', age:20, gender: '女'},
            {name: '李四', age:21, gender: '男'},
            {name: '赵小花', age:21, gender: '女'},
        ];

        //2. 引入 Student 组件
        class Student extends React.Component{
            render(){
                //2. 获取组件标签中的属性信息  this.props
                // console.log(this.props);
                let {name, age, gender} = this.props;
                return <div>
                        <ul>
                            <li>姓名: {name}</li>
                            <li>年龄: {age}</li>
                            <li>性别: {gender}</li>
                        </ul>
                        <hr />
                    </div>
            }
        }

        //3. 渲染虚拟 DOM 到容器
        ReactDOM.render(<div>
                {
                    students.map((item, index) => {
                        return <Student key={index}  {...item} /> 
                    })
                }
            </div>, document.querySelector("#root"));




    </script>
</body>
</html>